﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Microsoft.TeamFoundation.VersionControl.Client;
using System.IO;
using Microsoft.TeamFoundation.Build.Client;

namespace BDV.TfsCustomActivities.BuildTasks
{
    /// <summary>
    /// Remap all shfb documentation sources to workspace's binaries folder
    /// </summary>
    [BuildActivity(HostEnvironmentOption.All)]
    public sealed class ShfbProjRedirigeReferencesSources : CodeActivity
    {
        /// <summary>
        /// Output path of the build (contains dll and xml doc files)
        /// </summary>
        [RequiredArgument]
        public InArgument<string> BuildOutputPath { get; set; }

        /// <summary>
        /// Project local path
        /// </summary>
        [RequiredArgument]
        public InArgument<string> LocalProject { get; set; }

        // If your activity returns a value, derive from CodeActivity<TResult>
        // and return the value from the Execute method.
        protected override void Execute(CodeActivityContext context)
        {
            // Obtain the runtime value of the Text input argument
            //Workspace wkSpace = context.GetValue(this.WorkSpace);
            var inputFile = new FileInfo(context.GetValue(this.LocalProject));
            var outputBinariesFolder = new DirectoryInfo(context.GetValue(this.BuildOutputPath));

            ShfbprojHelper.RedirrigeCheminsDocumentSource(inputFile, outputBinariesFolder);
        }
    }
}
